package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class findIOperation implements Ioperation {

    @Override
    public void work(BookList bookList) {
        System.out.println("查找图书！");
        System.out.println("请输入你要查找的书籍名字：");
        Scanner sc = new Scanner(System.in);
        String name = sc.nextLine();
        int currentSize = bookList.getUseSize();
        for (int i = 0; i < currentSize; i++) {
            Book book =bookList.getBooks(i);
            if (book.getName().equals(name)) {
                System.out.println("你要查找的书籍信息如下：");
                System.out.println(book);
                return;
            }

        }
        System.out.println("这里没有你要找的书籍！");
    }
}
